#—*—coding:utf-8 -*-
#@Time        :2022/7/18 11:22
#@Author      :dhx
#@File        :create_payed_coll.py
# @Software: PyCharm
from time import sleep
from pages.finance_page import FinancePage
from selenium.webdriver.common.by import By


class TestCreatPayed(FinancePage):
    url='http://192.168.3.133/crm/index.php?m=finance&a=add&t=paymentorder'
    people_locator = (By.ID, 'owner_name')  # 负责人
    option_person_locator = (By.XPATH, '//*[@id="d_content"]/tr[1]/td[1]/input')  # 选择负责人
    ok_person_locator = (By.XPATH, '/html/body/div[8]/div[3]/div/button[1]/span')  # 点击保存
    person_locator = (By.ID, 'payables')  # 应付款人
    option_locator = (By.XPATH, '//*[@id="data"]/tr/td[1]/input')  # 选择应收款
    save_locator = (By.XPATH, '/html/body/div[7]/div[3]/div/button[1]/span')  # 点击保存
    price_locator = (By.ID, 'money')  # 金额
    time_locator = (By.ID, 'pay_time')  # 收款时间

    status_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tbody/tr[7]/td[2]/input[1]')  # 收款状态
    desc_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tbody/tr[8]/td[2]/textarea')  # 描述
    f_save_locator = (By.XPATH, '/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td[2]/input[1]')  # 能最后保存
    def duty_person(self):
        """选择负责人"""
        self.driver.find_element(*self.people_locator).click()
        sleep(1)
    def first_option(self):
        """勾选第一个"""
        self.driver.find_element(*self.option_person_locator).click()
        sleep(1)
    def save_option_one(self):
        """保存"""
        self.driver.find_element(*self.ok_person_locator).click()
        sleep(1)
    def input_pay_person(self):
        """输入收款人"""
        self.driver.find_element(*self.person_locator).click()
        sleep(1)
    def first_pay(self):
        """勾选第一个"""
        self.driver.find_element(*self.option_locator).click()
        sleep(1)
    def sa_pay(self):
        """点击保存"""
        self.driver.find_element(*self.save_locator).click()
        sleep(1)
    def input_price(self):
        """输入金额"""
        self.driver.find_element(*self.price_locator).send_keys("1000")
        sleep(1)
    def mod_price(self):
        """清空并修改"""
        self.driver.find_element(*self.price_locator).clear()
        sleep(1)
        self.driver.find_element(*self.price_locator).send_keys("20")
        sleep(2)
    def time_pay(self):
        """输入收款时间"""
        self.driver.find_element(*self.time_locator).send_keys("2022-08-10")
        sleep(1)
    def status_pay(self):
        """选择状态"""
        self.driver.find_element(*self.status_locator).click()
        sleep(1)
    def desc_pay(self):
        """输入描述"""
        self.driver.find_element(*self.desc_locator).send_keys("描述")
        sleep(1)
    def f_save_pay(self):
        """输入描述"""
        self.driver.find_element(*self.f_save_locator).click()
        sleep(1)
